var $ = getApp(), methods = require("../../methods.js");
Page(Object.assign({}, methods, {
	data: {
    type:'juli',
		longitude:'',
		latitude:'',
		datalist: [],
		pagenum: 1,
		keyword:'',
        cid:0,
        diqulist:[],
        showbox:false,
        numlist:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],
        chouhaonum:0
	},
	_onLoad:function(){
		var that = this
		if(that.options && that.options.cid){
			that.setData({cid:that.options.cid});
		}
        
		that.setData({ pagenum: 1, datalist: [], $nomoreData: false });
		that.getDataList();
	},
	getDataList: function () {
		var that = this
		var pagenum = that.data.pagenum
		var latitude = that.data.latitude
		var longitude = that.data.longitude
		var keyword = that.data.keyword
		console.log(keyword)
		that.setData({loaddingmore:true})
        $.post('yuxun/getChouhaoList', { pagenum: pagenum}, function (res) {
			that.setData({loaddingmore:false})
			var data = res.data
			if (pagenum == 1) {
				that.setData({ datalist: data });
				if (data.length == 0) {
					$.showEmpty('暂无相关数据！');
				}
			} else {
				if (data.length == 0) {
					that.setData({ $nomoreData: true });
				} else {
					var datalist = that.data.datalist
					var newdata = datalist.concat(data)
					that.setData({ datalist: newdata });
				}
			}
			that.setData({
				sclist: data
			});
		},false);
	},
	onReachBottom: function () {
		if (!this.data.$dataEmpty.visible && !this.data.$nomoreData) {
			this.setData({ pagenum: this.data.pagenum + 1 })
			this.getDataList();
		}
    },
    hidebox:function(){
        this.setData({showbox:false})
    },
    chouhao:function(e){
        this.setData({showbox:true});
        var that = this;
        var diaochang_id = e.currentTarget.dataset.diaochang_id;
        var diaochang_info_id = e.currentTarget.dataset.diaochang_info_id;
        $.post('yuxun/chouhao', { diaochang_id: diaochang_id,diaochang_info_id:diaochang_info_id}, function (res) {
            if(res.status==1){
                that.setData({chouhaonum:res.chouhaonum});
                that.getDataList();
            }else{
                $.error(res.msg)
            }
        })
    }
  
}))